package com.gmrz.webauthn.protocol.v1.schema;

import com.google.gson.annotations.SerializedName;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public enum UserVerificationRequirement {
    @SerializedName("required")
    REQUIRED("required"),

    @SerializedName("preferred")
    PREFERRED("preferred"),

    @SerializedName("discouraged")
    DISCOURAGED("discouraged");

    private static final Logger LOG = LogManager.getLogger(UserVerificationRequirement.class);
    private String mValue;

    private UserVerificationRequirement(String mValue) {
        this.mValue = mValue;
    }

    public String toString() {
        return this.mValue;
    }

    public static UserVerificationRequirement forName(String strValue) {
        for (UserVerificationRequirement value : values()) {
            if (value.mValue.equals(strValue)) {
                return value;
            }
        }

        String errorMsg = " UserVerificationRequirement has invalid value : " + (strValue.trim().equals("") ? "EMPTY" : strValue);
        LOG.error(errorMsg);
        throw new IllegalArgumentException(errorMsg);
    }
}
